<!DOCTYPE HTML>
<html class="error-page no-js" lang="zh_CN">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

<title>代码生成器1.0</title> #required_css
</head>

<body>
	<div class="center-wrapper">
		<div class="center-content text-center">
			<div class="row no-m">
				<div class="col-xs-10 col-xs-offset-2 col-sm-10 col-sm-offset-6 col-md-8 col-md-offset-2">
					<form action="$!basePath/open/dev/code/step/3" method="post" onsubmit = "return checkSelect()">
						<input type="hidden" name="catalog" value="$!catalog"/>
						<section class="panel bg-white no-b fadeIn animated shadow">
							<div class="panel-heading">
								<h2>选择数据库表</h2>
								<h4>2/4</h4>
								<div class="row">
									<div class="col-lg-12">
										<div class="input-group">
										<input type="text" class="form-control" placeholder="筛选..." onkeyup="filter(this.value)">
										<span class="input-group-btn">
											<button type="button" class="btn btn-primary fa fa-search"></button>
										</span>
									</div>
									</div>
								</div>
							</div>
							<div class="panel-body text-left" style="height:300px; overflow: auto;">
								<table id="tableNameTable" class="table">
									<thead>
										<tr>
											<th class="col-lg-1"><input type="checkbox" onclick="checkAll(this)"/></th>
											<th class="col-lg-8">表名</th>
										</tr>
									</thead>
									<tbody>
										#foreach($!obj in $!list)
										<tr>
											<td>
												<input type="checkbox" name="tables" value="$!obj"/>
											</td>
											<td>$!obj</td>
										</tr>
										#end
									</tbody>
								</table>
							</div>
							<div class="panel-footer">
								<button class="btn btn-primary">下一步</button>
							</div>
						</section>
					</form>
				</div>
			</div>
		</div>
	</div>
	#required_js
	<script type="text/javascript">
		function checkSelect(){
			var len = $("form input:checked").length;
			if(len == 0){
				alert("至少需要选择一张表！");
				return false;
			}
			return true;
		}
		function filter(key){
			$("#tableNameTable tbody tr").each(function(i, n){
				var tr = $(n);
				var name = tr.find("td:eq(1)").text();
				if(name.indexOf(key) >= 0){
					tr.show();
				}else{
					tr.hide();
				}
			});
		}
		function checkAll(chk){
			if($(chk).is(":checked"))
				$("#tableNameTable tbody input:checkbox:not(:hidden)").prop("checked", true);
			else
				$("#tableNameTable tbody input:checkbox").prop("checked", false);
				
		}
	</script>
</body>
</html>